package com.atguigu.gmall.realtime.bean

import com.atguigu.gmall.realtime.util.MyBeanUtil

import java.text.SimpleDateFormat

case class OrderWideNew(
  var detail_id: Long =0L,
  var  order_id:Long=0L,
  var  sku_id: Long=0L,
  var  order_price: Double=0D,
  var  sku_num:Long=0L,
  var  sku_name: String=null,
  var  split_total_amount:Double=0D,
  var  split_activity_amount:Double=0D,
  var  split_coupon_amount:Double=0D,

  var  province_id: Long=0L,
  var  order_status: String=null,
  var  user_id: Long=0L,
  var  total_amount:  Double=0D,
  var  activity_reduce_amount: Double=0D,
  var  coupon_reduce_amount: Double=0D,
  var  original_total_amount: Double=0D,
  var  feight_fee: Double=0D,
  var  feight_fee_reduce: Double=0D,
  var  expire_time: String =null,
  var  refundable_time:String =null,
  var  create_time: String=null,
  var operate_time: String=null,
  var create_date: String=null,
  var create_hour: String=null,

  var province_name:String=null,
  var province_area_code:String=null,
  var province_3166_2_code:String=null,
  var province_iso_code:String=null,

  var user_age :Int=0,
  var user_gender:String=null,

  // 商品信息
  var tm_id:Long=0L,
  var tm_name:String=null,
  var category3_id:Long=0L,
  var category3_name:String=null,
  var spu_id:Long=0L,
  var spu_name:String=null,

  var coupon_id:Long=0L ,
  var coupon_name:String=null,
  var coupon_type:String=null ,
  var coupon_condition_amount:Double=0D,
  var coupon_condition_num:Long=0L,


  var activity_id:Long=0L,
  var activity_rule_id:Long =0L,
  var activity_name:String=null,
  var activity_type:String =null,
  var activity_condition_amount:Double=0D,
  var activity_condition_num:Long=0L

 )
{
    def this(orderInfo: OrderInfo, orderDetail: OrderDetail) {
      this
      mergeOrderInfo(orderInfo)
      mergeOrderDetail(orderDetail)

    }

    def mergeOrderInfo(orderInfo: OrderInfo): Unit = {
      if (orderInfo != null) {

        MyBeanUtil.copyProperties(orderInfo,this)
        //   BeanUtils.copyProperties(this,orderInfo)
        this.order_id=orderInfo.id
        val dateTimeArr: Array[String] = orderInfo.create_time.split(" ")
        this.create_date= dateTimeArr(0)
        this.create_hour= dateTimeArr(1).split(":")(0)

      }
    }


    def mergeOrderDetail(orderDetail: OrderDetail): Unit = {
      if (orderDetail != null && orderDetail.id!=0) {
        MyBeanUtil.copyProperties(orderDetail,this )
        this.detail_id= orderDetail.id
      }
    }

  def mergeOrderCoupon(orderDetailCoupon: OrderDetailCoupon ): Unit = {
    if (orderDetailCoupon != null&&orderDetailCoupon.id!=0) {
      MyBeanUtil.copyProperties(orderDetailCoupon,this)

    }
  }

  def mergeOrderActivity(orderDetailActivity: OrderDetailActivity ): Unit = {
    if (orderDetailActivity != null&&orderDetailActivity.id!=0) {
      MyBeanUtil.copyProperties(orderDetailActivity,this)

    }
  }


}
